import axios from 'axios'
// import { stringifyQuery } from 'vue-router';

export const http = 'http://192.168.124.17:8099'

const service = axios.create({
    baseURL:http,
    timeout:100000
})

service.interceptors.request.use(config => {
    // config.isForm ?
    //     config.headers["content-type"] = "application/x-www-form-urlencoded" :
    //     config.headers["content-type"] = "application/json";
    config.headers["token"] = "xuchong";
    return config
}, error => {
    Promise.reject(error)
})

export const post = (url: string,data: object) => {
    return new Promise((resolve,reject) => {
        service({
            url,
            method:'post',
            data:data,
        }).then(res => {
            resolve(res)
        }).catch(error => {
            reject(error)
        })
    })
}

export const get = (url: string,data: object) => {
    return new Promise((resolve,reject) => {
        service({
            url,
            method:'get',
            params:data,
        }).then(res => {
            resolve(res)
        }).catch(error => {
            reject(error)
        })
    })
}
